package main

import (
	"fmt"
	"math/rand"
)

func main() {
	fmt.Println("[作业一]++++++++++++++++++++++++++++++++++++++++")
	for i := 1; i <= 9; i++ {
		for j := 1; j <= i; j++ {
			fmt.Printf("%-7s", fmt.Sprintf("%d*%d=%d", j, i, j*i))
		}
		fmt.Println()
	}

	fmt.Println("[作业二]++++++++++++++++++++++++++++++++++++++++")
	var sum, product int = 0, 1
	for i := 1; i <= 20; i++ {
		// 20 以内， 随机数范围 [1,20]
		v := rand.Intn(20) + 1
		fmt.Printf("%d ", v)
		if i&1 == 1 {
			sum += v
			continue
		}
		product *= v
	}
	fmt.Printf("\n求和:%d, 乘积:%d\n", sum, product)

	fmt.Println("[作业三]++++++++++++++++++++++++++++++++++++++++")
	// F(1)=1，F(2)=1, F(n)=F(n-1)+F(n-2) (n>=3，n∈N*)
	var n, i, j = 0, 1, 1
	for {
		n++
		if n > 2 {
			i, j = j, i+j
		}
		if j <= 100 {
			fmt.Printf("%d\t", j)
			continue
		}
		break
	}
}

// 阿飞老师的批改
// 代码逻辑清晰明了
